package views
{
	
	import flash.events.MouseEvent;
	import flash.text.StyleSheet;
	import flash.text.TextFieldAutoSize;
	
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.core.Container;
	import qnx.ui.core.ContainerFlow;
	import qnx.ui.core.SizeUnit;
	import qnx.ui.listClasses.ScrollDirection;
	import qnx.ui.listClasses.ScrollPane;
	import qnx.ui.text.Label;

	public class StatusView extends BaseView
	{
		private var scrlr:ScrollPane;
		private var statusText:Label;
		private var statusStr:String;

		public function StatusView()
		{
			super();
			configUI();
		}

		private function configUI():void
		{
			scrlr = new ScrollPane();
			//scrlr.setPosition(0, 0);
			scrlr.size = 100;
			scrlr.sizeUnit = SizeUnit.PERCENT;
			scrlr.scrollDirection = ScrollDirection.VERTICAL;

			var css:StyleSheet = new StyleSheet();
			css.setStyle("body", {fontFamily:'Courier New', fontSize:'18'});

			
			statusText = new Label();
			statusText.autoSize = TextFieldAutoSize.LEFT;
			statusText.multiline = true;
			statusText.textField.wordWrap = true;
			statusText.width = 1020;
			statusText.textField.styleSheet = css;
			statusText.selectable = true;
			statusText.htmlText = "<body>";
			//statusText.height = 470;
			scrlr.setScrollContent(statusText);
			
			var mainContainer:Container = new Container();
			//mainContainer.margins = Vector.<Number>([2,2,2,2]);
			mainContainer.flow = ContainerFlow.HORIZONTAL;
			//mainContainer.debugColor = 0xFFCC00;
			this.addChild(mainContainer);
			
			mainContainer.addChild(scrlr);
			//mainContainer.addChild(bt_close);
			mainContainer.setSize(1024, 540);
		}
		
		public function appendHTML(txt:String):void
		{
			/*if(!this.isOnStage){
				statusStr += txt;
				return;
			}*/
			statusText.htmlText += txt;
			if(statusText.textHeight > scrlr.height){
				scrlr.scrollY = statusText.textHeight;
				scrlr.update();
			}
			
		}
		
		/*
		protected override function onRemoved():void
		{
			if(statusText.htmlText.length > statusStr.length){
				statusStr = statusText.htmlText;
			}
		}
		
		protected override function onAdded():void
		{
			if(statusText.htmlText.length < statusStr.length){
				statusText.htmlText = statusStr;
				if(statusText.textHeight > scrlr.height){
					scrlr.scrollY = statusText.textHeight;
					scrlr.update();
				}
			}
		}*/
	}

}